package com.cskaoyan.service;
/*
 * @author 魏骏杰
 */

import com.cskaoyan.bean.statistics.BaseStatisticsParam;
import com.cskaoyan.bean.statistics.GoodsDataStatistics;
import com.cskaoyan.bean.statistics.OrderDataStatistics;
import com.cskaoyan.bean.statistics.UserDataStatistics;
import com.cskaoyan.mapper.StatisticsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class StatisticsServiceImpl implements StatisticsService {
    @Autowired
    StatisticsMapper statisticsMapper;

    @Override
    public BaseStatisticsParam getUserDateList() {
        BaseStatisticsParam baseStatisticsParam = new BaseStatisticsParam();
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("users");
        baseStatisticsParam.setColumns(columns);

        List<UserDataStatistics> rows = statisticsMapper.selectUserDateList();
        baseStatisticsParam.setRows(rows);
        return baseStatisticsParam;
    }

    @Override
    public BaseStatisticsParam getOrderDateList() {
        BaseStatisticsParam baseStatisticsParam = new BaseStatisticsParam();
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("customers");
        columns.add("amount");
        columns.add("pcr");
        baseStatisticsParam.setColumns(columns);

        List<OrderDataStatistics> rows = statisticsMapper.selectOrderDateList();
        baseStatisticsParam.setRows(rows);
        return baseStatisticsParam;
    }

    @Override
    public BaseStatisticsParam getGoodsDateList() {
        BaseStatisticsParam baseStatisticsParam = new BaseStatisticsParam();
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("products");
        columns.add("amount");
        baseStatisticsParam.setColumns(columns);

        List<GoodsDataStatistics> rows = statisticsMapper.selectGoodsDateList();
        baseStatisticsParam.setRows(rows);
        return baseStatisticsParam;
    }
}
